package cn.tsvtc.shop.controller;


import cn.tsvtc.shop.Service.BannerService;
import cn.tsvtc.shop.Service.ProductTypeService;
import cn.tsvtc.shop.pojo.Banner;
import cn.tsvtc.shop.pojo.ProductType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletResponse;
import java.util.List;


/**
 * @author: Athena
 * @date: 2020/10/30 13:15
 * @description:
 */
@Controller
@RequestMapping("page")
@Slf4j
public class PageController {

    private BannerService bannerService;

    private RedisTemplate redisTemplate;

    private ProductTypeService productTypeService;

    @Autowired
    public PageController( RedisTemplate redisTemplate,ProductTypeService productTypeService,BannerService bannerService){
        this.redisTemplate=redisTemplate;
        this.productTypeService=productTypeService;
        this.bannerService=bannerService;
    }

    /**
     * 返回templates的注册页面index.html
     * @return String
     */
    @GetMapping("index")
    public String register(Model model) {
        List<ProductType> list = productTypeService.findAll();
        List<Banner> bannerlist = bannerService.findAll();
        model.addAttribute("types",list);
        model.addAttribute("banners",bannerlist);
        return "index.html";

    }

}
